package com.lagou.edu.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/login")
public class LoginController {

    @RequestMapping(value = "/check",method = RequestMethod.POST)
    @ResponseBody
    public String check(HttpServletRequest request, String username,String password ) {
        if ("admin".equals(username) && "admin".equals(password)) {
            HttpSession session = request.getSession();
            System.out.println(session.getAttribute("loginUser"));
            session.setAttribute("loginUser","admin");
            return "true";
        }
        return "false";
    }
}
